<?php
/**
 * usergroup_model Class
 *
 */
class Usergroup_model extends Model {
	/**
	 * Constructor
	 */
	function Usergroup_model()
	{
		parent::Model();
	}
	
	// Inisialisasi nama tabel yang digunakan
	var $table = 'usergroup';
	
	/**
	 * Mendapatkan semua data usergroup, diurutkan berdasarkan id_usergroup
	 */
	function get_usergroup()
	{
		$this->db->order_by('id_usergroup');
		return $this->db->get('usergroup');
	}
	
	/**
	 * Mendapatkan data sebuah usergroup
	 */
	function get_usergroup_by_id($id_usergroup)
	{
		return $this->db->get_where($this->table, array('id_usergroup' => $id_usergroup), 1)->row();
	}
	
	function get_all()
	{
		$this->db->order_by('id_usergroup');
		return $this->db->get($this->table);
	}
	
	/**
	 * Menghapus sebuah data usergroup
	 */
	function delete($id_usergroup)
	{
		$this->db->delete($this->table, array('id_usergroup' => $id_usergroup));
	}
	
	/**
	 * Tambah data usergroup
	 */
	function add($usergroup)
	{
		$this->db->insert($this->table, $usergroup);
	}
	
	/**
	 * Update data usergroup
	 */
	function update($id_usergroup, $usergroup)
	{
		$this->db->where('id_usergroup', $id_usergroup);
		$this->db->update($this->table, $usergroup);
	}
	
	/**
	 * Validasi agar tidak ada usergroupd dengan id ganda
	 */
	function valid_id($id_usergroup)
	{
		$query = $this->db->get_where($this->table, array('id_usergroup' => $id_usergroup));
		if ($query->num_rows() > 0)
		{
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}
}
// END Siswa_model Class

/* End of file usergroup_model.php */
/* Location: ./system/application/models/usergroup_model.php */